package cn.zyq.ykb.controller.mgt.advert;


import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.beans.advert.Advert;
import cn.zyq.ykb.service.advert.AdvertService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.zyq.ykb.system.common.PageParam;



/**
 * 悦推客广告Controller
 *
 * @author SystemAuth
 * @date 2024-09-28
 */

@RestController(value = "MgtAdvertController")
@RequestMapping("/mgt/advert")
@Api(tags = "悦推客广告接口")
public class AdvertController extends BaseController {

    @Autowired
    private AdvertService advertService;

    /**
     * 查询悦推客广告列表
     */
    @ApiOperation(value = "列表", response = Advert.class)
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.advertService.selectAdvertList(pageParam);
    }

    /**
     * 获取悦推客广告详细信息
     */
    @ApiOperation(value = "详情", response = Advert.class)
    @GetMapping(value = "/{advertID}")
    public Object getInfo(@PathVariable("advertID") Integer advertID) {
        return this.advertService.selectAdvertByAdvertID(advertID);
    }

    /**
     * 新增悦推客广告
     */
    @ApiOperation(value = "新增")
    @Log(title = "悦推客广告", businessType = BusinessType.INSERT)
    @PostMapping
    public Object add(@RequestBody Advert advert) {
        return this.advertService.insertAdvert(advert);
    }

    /**
     * 修改悦推客广告
     */
    @ApiOperation(value = "编辑")
    @Log(title = "悦推客广告", businessType = BusinessType.UPDATE)
    @PutMapping
    public Object edit(@RequestBody Advert advert) {
        return this.advertService.updateAdvert(advert);
    }

}
